/*
 * @Description  : 
 * @Date         : 2021-08-26 15:05:09
 * @Author       : 保锋
 * @LastEditTime : 2021-08-26 15:42:05
 * @LastEditors  : 保锋
 * @FilePath     : \flutter_demo\lib\pages\car_number_input_dialog\car_number_input_dialog_demo.dart
 */
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'car_number_input_dialog.dart';

class CarNumberInputDialogPage extends StatelessWidget {
  CarNumberInputDialogPage({Key? key}) : super(key: key);
  final CarNumberInputDialogPageController vm =
      Get.put(CarNumberInputDialogPageController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('车牌号输入'),
      ),
      body: Column(
        children: [
          GestureDetector(onTap: () {
            if (vm.isOpenKeyboard) {
            } else {
              Get.bottomSheet<bool>(
                CarNumberInputDialog(
                  initCarNumber: vm.carNumber,
                ),
                backgroundColor: Colors.transparent,
                barrierColor: Colors.transparent,
              ).then((value) {
                print(value);
                vm.isOpenKeyboard = false;
              });
            }
          }, child: Obx(() {
            return Text(
                vm.carNumber.value == '' ? '请输入车牌号' : vm.carNumber.value);
          }))
        ],
      ),
    );
  }
}

class CarNumberInputDialogPageController extends GetxController {
  ///车牌键盘是否弹起
  bool isOpenKeyboard = false;

  ///车牌号
  RxString carNumber = ''.obs;
}
